import request from '@/router/axios';

export const updateSensorCapacity = (id) => {
    return request({
        url: '/api/uic-system/fillmachine/refreshSensorWaterlep',
        method: 'get',
        params: {id}
    })
}


export const getSyncAll = async () => {
    return await request({
        url: '/api/uic-system/fillmachine/all',
        method: 'get',
        params: {
            onlyViewWarnMachine: true
        }
    })
}

export const getAllBySearch = (params) => {
    return request({
        url: '/api/uic-system/fillmachine/all',
        method: 'get',
        params
    })
}


export const getPage = (page, params) => {
    return request({
        url: '/api/uic-system/fillmachine/page',
        method: 'get',
        params: {
            ...page,
            ...params,
        }
    })
}

export const saveOrUpdate = (form) => {
    return request({
        url: '/api/uic-system/fillmachine/submit',
        method: 'post',
        data: {
            ...form
        }
    })
}

export const getDeviceNetworkSignal = (machineId) => {
    return request({
        url: `/api/uic-system/fillmachine/getDeviceNetworkSignal?id=${machineId}`,
        method: 'get',
    })
}

export const getQRCode = (id) => {
    return request({
        url: '/api/uic-system/fillmachine/getQRCode',
        method: 'get',
        responseType: 'blob',
        header: {
            "Accept": "image/png"
        },
        params: {id}
    })
}

export const getQRCode2 = (id) => {
    return request({
        url: '/api/uic-system/fillmachine/getQRCode',
        method: 'get',
        params: {id}
    })
}

// 安装记录
export const installRecordPage = (page, params) => {
    return request({
        url: '/api/uic-system/fillmachineinstallrecord/page',
        method: 'get',
        params: {
            ...page,
            ...params,
        }
    })
}

export const installFillingMachine = (form) => {
    return request({
        url: '/api/uic-system/fillmachineinstallrecord/submit',
        method: 'post',
        data: {
            ...form,
        }
    })
}

export const batchSetPrices = (data) => {
    return request({
        url: '/api/uic-system/fillmachinepriceset/submit',
        method: 'post',
        data
    })
}

export const getListByTeamId = (teamId) => {
    return request({
        url: '/api/uic-system/fillmachine/list',
        method: 'get',
        params: {
            size: 500,
            teamId
        }
    })
}

// 余量汇总
export const summary = () => {
    return request({
        url: '/api/uic-system/fillmachinestoragewater/summary',
        method: 'get',
    })
}

// 余量校准
export const adjust = (data) => {
    return request({
        url: '/api/uic-system/fillmachinestoragewater/save',
        method: 'post',
        data
    })
}

// 余量历史
export const getAdjustHistoryPage = (page, params) => {
    return request({
        url: '/api/uic-system/fillmachinestoragewater/page',
        method: 'get',
        params: {
            ...page,
            ...params,
        }
    })
}


export const detailFromIotByMacCode = (macCode) => {
    return request({
        url: '/api/uic-system/fillmachine/detailFromIotByMacCode',
        method: 'get',
        params: {
            macCode
        }
    })
}

export const getDeviceIsOnline = (macCode) => {
    return request({
        url: '/api/uic-system/fillmachine/getDeviceIsOnline',
        method: 'get',
        params: {
            macCode
        }
    })
}


export const syncBasicAttrByMacCode = (macCode) => {
    return request({
        url: '/api/uic-system/fillmachine/syncBasicAttrByMacCode',
        method: 'get',
        params: {
            macCode
        }
    })
}
